Page 77 - 2629_Devagiri_C-8
P. 77
PRIMARY KEY constraint: The Primary key constraint uniquely identifies each record in a table.
Primary keys must be unique, cannot be NULL and only one primary key can exists per table. QR QUEST
FOREIGN KEY constraint: The Foreign key constraint is used to establish a relationship Visit the given link
between two tables. It ensures that the values in a column in one table match the values in the to learn about Constraints
primary key column of another table. in SQL:
https://www.youtube.com/watch?v=-
UNIQUE constraint: The Unique constraint ensures that each value in a column is unique. 8bYtApJNos
Answer the given questions:
DEFAULT constraint: The Default constraint is used to specify a default value for a column.
If no other value is specified, the default value will be added to all new records. 1. Why are constraints important
in a database?
CHECK constraint: The Check constraint restricts the range of values that can be stored in a 2. Explain any two SQL
column by enforcing a specified condition. constraints.
RAPID RECALL Tick ( ) if you know this. USING DATABASE
To work with a specific database, you must first select it using the
1. Arithmetic operators perform basic mathematical operations on numerical data. USE command. The syntax is as follows:
2. DML is a language that enables users to retrieve, update, insert and delete data. USE database_name;
DELETING DATABASE
If you no longer need a database, you can delete it. However, this action is permanent and
CREATING, VIEWING AND DELETING A DATABASE removes all tables and data within the database. Always ensure that you have a backup before
deleting a database.
Creating, viewing and deleting are basic database management tasks. They help set up new The syntax to delete a database is:
databases, check existing ones and remove those that are no longer needed.
DROP DATABASE database_name;
CREATING DATABASE
The CREATE DATABASE command is used to create a database in MySQL. Once the database is CREATING AND MANAGING TABLES
created, you can begin adding tables, storing data and running queries.
The syntax to create a database is: In MySQL, tables are the fundamental building blocks of a database for storing data in an
organised mannner. Table management involves creating, viewing, modifying and deleting these
CREATE DATABASE database_name;
structures as needed.
The command to create a School database is as follows:
CREATING TABLES
A table, also known as a relation, organizes data into rows and columns. To create one, you use
the CREATE TABLE command. The syntax is as follows:
CREATE TABLE table_name
(
VIEWING DATABASE column_name1 data_type(size),
column_name2 data_type(size),
To view a list of existing databases, the following command is used:
column_name3 data_type(size),
SHOW DATABASES; .....
75
MySQL: My First Database

